package com.tricode.ile.training.task.ESAD.four;

/**
 * Point out and remove the code smells in the code below (this example is contributed by Carita):
 */

public abstract class Payment {
    int units;
    double rate;
    final double TAX_RATE = 0.1;

    public int getUnits() {
        return units;
    }

    public void setUnits(int units) {
        this.units = units;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }

    public abstract double getBillableAmount();

    protected double createBaseAmt() {
        return units * rate;
    }

    protected double calculateBillableAmount(double baseAmt, double tax) {
        return baseAmt + tax;
    }
}

class NormalPayment extends Payment{
    public double getBillableAmount() {
        double baseAmt = createBaseAmt();
        double tax = baseAmt * TAX_RATE;
        return calculateBillableAmount(baseAmt, tax);
    }
}

class PaymentForSeniorCitizen extends Payment{
    public double getBillableAmount() {
        double baseAmt = createBaseAmt() * 0.8;
        double tax = baseAmt * (TAX_RATE - 0.5) ;
        return calculateBillableAmount(baseAmt, tax);
    }
}
